<%--
  作者:张伟

  联系:adamzzww@163.com
  时间:2016-11-28
  说明:新增or编辑员工信息
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <title><%=Global.TITLE%>
    </title>
    <%@include file="../../desktop/include/assets.jsp" %>
    <link href="<%=_asset_path%>/zui-1.5.0/lib/datetimepicker/datetimepicker.min.css" rel="stylesheet">
    <script type="text/javascript" src="<%=_asset_path%>/zui-1.5.0/lib/datetimepicker/datetimepicker.min.js"></script>
    <%
        String url = request.getContextPath() + Global.PATH + "/employee";
    %>
    <style>

    </style>
</head>
<body>
<div class="page-wrapper">

    <%@include file="../../desktop/include/navigator.jsp" %>

    <div style="margin:20px;">
        <form id="editForm" name="editForm" class="form-horizontal form-condensed" role="form" method="post"
              action="<%=url%>/save">
            <table class="table table-bordered">
                <tbody>
                <tr>
                    <th>基本信息
                    </th>
                </tr>
                <tr>
                    <td>
                        <table class="table table-bordered">
                            <tbody>
                            <tr>
                                <th><label class="control-label required" for="employeeName">姓名：</label></th>
                                <td>
                                    <input value="${entity.employeeName}" class="form-control" name="employeeName"
                                           type="text" id="employeeName"></td>
                                <th><label class="control-label required" for="identityCard">证件号码：</label></th>
                                <td>
                                    <input value="${entity.identityCard}" class="form-control" name="identityCard"
                                           type="text" id="identityCard"></td>
                                <td rowspan="4">
                                    <c:if test="${empty entity.avatar}">
                                        <img data-toggle="lightbox" class="img-thumbnail" alt="员工头像" width="100px"
                                             height="120px"
                                             src="<%=request.getContextPath()%>/assets/upload/avatar/guest.jpg">
                                    </c:if>
                                    <c:if test="${not empty entity.avatar}">
                                        <img data-toggle="lightbox" class="img-thumbnail" alt="员工头像" width="100px"
                                             height="120px"
                                             src="<%=request.getContextPath()%>/assets/upload/avatar/${entity.avatar}">
                                    </c:if>
                                </td>
                            </tr>
                            <tr>
                                <th><label class="control-label required" for="employeeSn">员工编号：</label></th>
                                <td><input value="${entity.employeeSn}" class="form-control" name="employeeSn"
                                           type="text" id="employeeSn"></td>
                                <th><label class="control-label required" for="employeeSn">性别：</label></th>
                                <td><input name="sex" type="radio" value="1"
                                           <c:if test="${entity.sex == 1}">checked="checked"</c:if>>男
                                    <input name="sex" type="radio" value="0"
                                           <c:if test="${entity.sex == 0}">checked="checked"</c:if>>女
                                </td>
                            </tr>
                            <tr>
                                <th><label class="control-label required" for="birthDay">出生日期：</label></th>
                                <td>
                                    <input class="form-control form-date" value="${entity.birthDay}"
                                           name="birthDay" type="text" id="birthDay">
                                </td>
                                <th><label class="control-label required" for="phone">手机号：</label></th>
                                <td><input class="form-control" value="${entity.phone}" name="phone" type="text"
                                           id="phone"></td>
                            </tr>
                            <tr>
                                <th><label class="control-label required" for="nativePlace">籍贯：</label></th>
                                <td>
                                    <input value="${entity.nativePlace}" class="form-control"
                                           name="nativePlace" type="text" id="nativePlace"></td>
                                <th><label class="control-label required" for="curDept">所属部门：</label></th>
                                <td>
                                    <select name="curDept" id="curDept" class="form-control">
                                        <c:if test="${!empty deptList }">
                                            <c:forEach items="${deptList }" var="dept">
                                                <option value="${dept.deptId}" ${entity.curDept == dept.deptId ?"selected":""}>${dept.deptName}</option>
                                            </c:forEach>
                                        </c:if>
                                    </select>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td><font color="red">注：身份证号末位如果为英文字母x，必须要大写。<br>
                    </font>
                    </td>
                </tr>

                <tr>
                    <th>其他基本信息</th>
                </tr>
                <tr>
                    <td>
                        <table style="border-collapse: collapse" bordercolor="#666666" cellspacing="0" cellpadding="3"
                               width="100%" border="1">
                            <tbody>
                            <tr>
                                <th><label class="control-label required" for="messageAddress">通讯地址：</label></th>
                                <td colspan="3">
                                    <input class="form-control" value="${entity.messageAddress}"
                                           name="messageAddress" type="text" id="messageAddress">
                                </td>
                            </tr>
                            <%--<tr>--%>
                            <%--<th>邮政编码：</th>--%>
                            <%--<td>--%>
                            <%--<input name="txtPostCode" type="text" maxlength="6" id="txtPostCode" class="inputBlue" style="width:100px;"></td>--%>
                            <%--<th>电子信箱：</th>--%>
                            <%--<td>--%>
                            <%--<input name="txtEmail" type="text" id="txtEmail" class="inputBlue"></td>--%>
                            <%--</tr>--%>
                            <%--<tr>--%>
                            <%--<th>紧急联系人：</th>--%>
                            <%--<td>--%>
                            <%--<input name="txtEmergencyContact" type="text" id="txtEmergencyContact" class="inputBlue" style="width:100px;"></td>--%>
                            <%--<th>联系电话：</th>--%>
                            <%--<td>--%>
                            <%--<input name="txtHomePhone" type="text" id="txtHomePhone" class="inputBlue" style="width:100px;"></td>--%>
                            <%--</tr>--%>
                            <%--<tr>--%>
                            <%--<th>婚姻状况：</th>--%>
                            <%--<td>--%>
                            <%--<span id="rblMarrige"><input id="rblMarrige_0" type="radio" name="rblMarrige" value="03" checked="checked"><label for="rblMarrige_0">其它</label><input id="rblMarrige_1" type="radio" name="rblMarrige" value="01"><label for="rblMarrige_1">未婚</label><input id="rblMarrige_2" type="radio" name="rblMarrige" value="02"><label for="rblMarrige_2">已婚</label></span></td>--%>
                            <%--<th>政治面貌：</th>--%>
                            <%--<td>--%>
                            <%--<select name="ddlPolitics" id="ddlPolitics" class="inputBlue" style="height:20px;width:100px;">--%>
                            <%--<option value="01">群众</option>--%>
                            <%--<option value="02">中共党员</option>--%>
                            <%--</select></td>--%>
                            <%--</tr>--%>

                            </tbody>
                        </table>
                    </td>
                </tr>

                <tr>
                    <th>
                        <input type="hidden" name="employeeId" value="${entity.employeeId}"/>
                        <input type="submit" name="btnSave" value="保存" id="btnSave" class="btn btn-primary">
                        <input type="button" name="btnReturn" value="返回" onclick="javascript:history.go(-1);"
                               class="btn">
                    </th>
                </tr>
                </tbody>
            </table>

        </form>

    </div>
</div>
<script>


    $(".form-date").datetimepicker({
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
        language: 'zh-CN', //汉化
        autoclose: true, //选择日期后自动关闭
        format: "yyyy-mm-dd",
    });

    $(function () {
        var validate = $("#editForm").validate({
            //debug: true, //调试模式取消submit的默认提交功能
            rules: {
                employeeName: {
                    required: true,
                },
                employeeSn: {
                    required: true,
                },
                identityCard: {
                    required: true,
                },
                sex: {
                    required: true,
                },
                phone: {
                    required: true,
                    digits: true
                },
                birthDay: {
                    required: true,
                    date: true,
                },
                messageAddress: {
                    required: true,
                },
            },
            messages: {
                employeeName: {
                    required: "请输入员工姓名",
                }
            },
            submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form
                //直接提交表单
                $.ajax({
                    url: form.action,
                    type: form.method,
                    data: $(form).serialize(),
                    success: function (data) {
                        // 提交表单
                        if (data == "success") {
                            alert("提交成功！");
                            window.location.href = '<%=url%>/list';
                        } else {
                            alert("提交失败！");
                        }
                    }
                });
            },
        });
    });
</script>
</body>
</html>
